home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 100
/
FreelogNo100-NovembreDecembre2010.iso
/
ViePratique
/
Calendar Magic
/
setup.exe
/
{app}
/
Quadratic.shf
< prev
next >
Wrap
Text File
|
2007-01-06
|
720b
|
24 lines
Degrees
' Quadratic Equation Solver
'
' Finds real or complex roots of the equation a*x^2 + b*x + c = 0.
' Coefficients a, b, c must be real numbers. a must be non-zero and at least one of b and c also non-zero.
' First root has real and imaginary parts Rx1 and Ix1 respectively. Second root is similarly defined.
'
a = 1
==> a = 1
b = 2
==> b = 2
c = 3
==> c = 3
D = b ^ 2 - 4 * a * c
==> D = -8
Rx1 = -b / (2 * a) - (1 + sign(D)) * sign(b) * sqrt(abs(D)) / (4 * a) + invert(b) * sqrt((1 - sign(c)) * abs(c / (2 * a)))
==> Rx1 = -1
Ix1 = (1 - sign(D)) * sqrt(abs(D)) / (4 * a)
==> Ix1 = 1.4142135623731
Rx2 = c * Rx1 / (a * (Rx1 ^ 2 + Ix1 ^ 2))
==> Rx2 = -1
Ix2 = -Ix1
==> Ix2 = -1.4142135623731